# Master Script to Create Log File

# Start logging
log_file <- "R_log.txt"
sink(log_file, append = TRUE)

cat("Replication started at:", Sys.time(), "\n")

# List of scripts to run
scripts <- c('1_initial_merging.R', '2_text_preprocessing.R',
             '4_creating_web_df.R', '5_data_coverage.R',
             '6_measurement_validation.R', '7_generating_analysisdf.R',
             '8_positioning_response.R', '8a_issue_uptake_response.R',
             '8b_issue_text_response.R')



# Run each script
for (script in scripts) {
  cat("\nRunning:", script, "at", Sys.time(), "\n")
  tryCatch(
    {
      source(script)
      cat("Completed:", script, "successfully.\n")
    },
    error = function(e) {
      cat("Error in", script, ":", conditionMessage(e), "\n")
    }
  )
}

cat("Replication completed at:", Sys.time(), "\n")

# Stop logging
sink()

sessionInfo()